home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 5 / DINKDEMO / DINKCLAS / DINKUTIL.C < prev    next >
Text File  |  1992-07-08  |  2KB  |  117 lines

  1. /*
  2.     File:        DinkUtils.c
  3.  
  4.     Written by:    Mark Gross
  5.  
  6.     Copyright:    ⌐ 1992 by Applied Technical Software, all rights reserved.
  7.     Use at your own risk.
  8.  
  9. */
  10.  
  11. // this file has a number of utility fuctions
  12. // for The DinkClass
  13. #include "DinkUtils.h"
  14. #include "DApplication.h"
  15. #include "DEventHandler.h"
  16. #include "DDocument.h"
  17. #include <Editions.h>
  18. #include <Traps.h>
  19. #include <GestaltEqu.h>
  20.  
  21. extern DApplication *DEventHandler::gApplication;
  22.  
  23. void InitToolBox(int numMoreMasers)
  24. {
  25.     int i;
  26.     EventRecord event;
  27.     
  28.     MaxApplZone();
  29.     for (i=0; i<numMoreMasers; i++)
  30.         MoreMasters();
  31.  
  32.     FlushEvents(everyEvent, 0);
  33.  
  34.     InitGraf(&thePort);
  35.     InitFonts();
  36.     InitWindows();
  37.     InitMenus();
  38.     TEInit();
  39.     InitDialogs( NULL);
  40.     InitCursor();
  41.     
  42.     InitEditionPack();
  43.     
  44.     for (i = 1; i <= 3; i++)
  45.         EventAvail(everyEvent, &event);
  46. }
  47.  
  48.  
  49.  
  50.  
  51. OSErr RequiredCheck( AppleEvent *theAppleEvent)
  52. {
  53.     OSErr myErr;
  54.     DescType typeCode;
  55.     Size actualSize;
  56.     
  57.     myErr = AEGetAttributePtr( theAppleEvent, keyMissedKeywordAttr, typeWildCard,
  58.                                 &typeCode, 0L, 0, &actualSize);
  59.     
  60.     if (myErr == errAEDescNotFound ) 
  61.         return noErr;
  62.     
  63.     if (myErr == noErr )
  64.         return errAEEventNotHandled ;
  65.     
  66.     return myErr;
  67. }
  68.  
  69. Boolean System7Available(void)
  70. {
  71.     long sysVersion;
  72.     
  73.     if( !TrapExists(_GestaltDispatch) ) 
  74.         return false;
  75.     
  76.     if( !Gestalt( gestaltSystemVersion, &sysVersion) )
  77.     {
  78.         if(sysVersion >= 0x0700) 
  79.             return true;
  80.     }
  81.     return false;
  82. }
  83.  
  84.  
  85. Boolean TrapExists(short theTrap)
  86. {
  87.     TrapType    theTrapType;
  88.  
  89.     theTrapType = GetTrapType(theTrap);
  90.     if ((theTrapType == ToolTrap) && ((theTrap &= 0x07FF) >= NumToolboxTraps()))
  91.         theTrap = _Unimplemented;
  92.  
  93.     return (NGetTrapAddress(_Unimplemented, ToolTrap) != NGetTrapAddress(theTrap,
  94.                   theTrapType));
  95. }
  96.  
  97. TrapType    GetTrapType(short theTrap)
  98. {
  99.     /* OS traps start with A0, Tool with A8 or AA. */
  100.     if ((theTrap & 0x0800) == 0)                    /* per D.A. */
  101.         return (OSTrap);
  102.     else
  103.         return (ToolTrap);
  104. }
  105.  
  106.  
  107.  
  108. short    NumToolboxTraps(void)
  109. {
  110.     if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E, ToolTrap))
  111.         return (0x200);
  112.     else
  113.         return (0x400);
  114. }
  115.  
  116.  
  117.